from rest_framework import serializers
from operation.models import SurgicalClassification, SurgicalDetails
from AskDoctor.models import DoctorModel
from AskDoctor.ser import DoctorSerializer

# 手术辅查序列化器
class SurgicalClassificationSerializer(serializers.ModelSerializer):

    class Meta:
        model = SurgicalClassification
        fields = [
            'id', 
            'examination_name'
        ]

# 辅查详情序列化器
class SurgicalDetailsSerializer(serializers.ModelSerializer):
    surgical = SurgicalClassificationSerializer(read_only=True)
    doctor = DoctorSerializer(allow_null=True, read_only=True)
    class Meta:
        model = SurgicalDetails
        fields = [
            'id', 
            'title', 
            'content', 
            'department', 
            'entry_author', 
            'publish_date', 
            'indications', 
            'contraindications', 
            'risks_and_complications', 
            'preoperative_attention', 
            'intoperative_attention', 
            'postoperative_attention', 
            'more_information', 
            'reference_materials', 
            'surgical'
        ]
